package com.nageoffer.shortlink.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nageoffer.shortlink.admin.common.convention.result.Result;
import com.nageoffer.shortlink.admin.remote.dto.ShortLinkRemoteService;
import com.nageoffer.shortlink.admin.remote.dto.req.ShortLinkCreateReqDTO;
import com.nageoffer.shortlink.admin.remote.dto.req.ShortLinkPageReqDTO;
import com.nageoffer.shortlink.admin.remote.dto.req.ShortLinkUpdateReqDTO;
import com.nageoffer.shortlink.admin.remote.dto.resp.ShortLinkCreateRespDTO;
import com.nageoffer.shortlink.admin.remote.dto.resp.ShortLinkGroupCountQueryRespDTO;
import com.nageoffer.shortlink.admin.remote.dto.resp.ShortLinkPageRespDTO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ShortLinkController {

   private final ShortLinkRemoteService shortLinkService = new ShortLinkRemoteService(){};

   @PostMapping("/api/short-link/admin/v1/create")
   public Result<ShortLinkCreateRespDTO> createShortLink(@RequestBody ShortLinkCreateReqDTO reqParam){
      return shortLinkService.createShortLink(reqParam);
   }

   @GetMapping("/api/short-link/admin/v1/page")
   public Result<IPage<ShortLinkPageRespDTO>> pageShortLink(ShortLinkPageReqDTO reqParam){
      return shortLinkService.pageShortLink(reqParam);
   }

   @GetMapping("/api/short-link/admin/v1/count")
   public Result<List<ShortLinkGroupCountQueryRespDTO>> listGroupShortLinkCount(List<String> requestParam){
      return shortLinkService.listGroupShortLinkCount(requestParam);
   }

   @PostMapping("/api/short-link/admin/v1/update")
   public Result<Void> updateShortLink(@RequestBody ShortLinkUpdateReqDTO reqParam){
      return shortLinkService.updateShortLink(reqParam);
   }


}
